﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace ContinuationDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Task<string> print = Task.Run(() =>
           {
               Thread.Sleep(1000);
               return "芜湖起飞";
           });

            //可直接抛出异常
            //var awaiter = print.GetAwaiter();
            //awaiter.OnCompleted(() =>
            //{
            //    var result = awaiter.GetResult();
            //    Console.WriteLine(result);
            //});

            //需要转换AggregateException异常处理
            print.ContinueWith(task =>
            {
                Console.WriteLine(task.Result);
            });

            Console.ReadLine();
        }
    }
}
